package com.car.dao.impl;

import com.car.dao.CarDao;
import com.car.domain.Car;
import org.junit.Test;

import java.util.List;

import static org.junit.Assert.*;

public class CarDaoImplTest {
    public final static CarDao carDao = new CarDaoImpl();

    @Test
    public void add() throws Exception {
        Car car = new Car();
        car.setName("SU7");
        car.setCarNum("132457");
        car.setBrand("xiaomi");
        car.setColor("米白色");
        car.setEmployeeId(1);
        car.setPrice(288888.0);
        car.setType("电动车");
        int add = carDao.add(car);
        System.out.println(add);
    }

    @Test
    public void delete() throws Exception {
        int delete = carDao.delete(1);
        System.out.println(delete);
    }

    @Test
    public void update() throws Exception {
        Car car = carDao.queryById(2);
        car.setName("小米汽车666");
        int update = carDao.update(car);
        System.out.println(update);
    }

    @Test
    public void queryById() throws Exception {
        Car car = carDao.queryById(2);
        System.out.println(car);
    }

    @Test
    public void queryAll() throws Exception {
        List<Car> cars = carDao.queryAll();
        System.out.println(cars);
    }
}